# 导包
import os
import sys


def tree_dir(dirPath, level=1):
    if level == 1:
        print(dirPath)
    dirs = os.listdir(dirPath)
    for dir in dirs:
        allFile = os.path.join(dirPath, dir)
        if os.path.isdir(allFile):
            print("\t"*level+"|"+"--"*level, dir)
            tree_dir(allFile, level+1)
        elif os.path.isfile(allFile):
            print("\t"*level+"|"+"--"*level, dir)


if __name__ == '__main__':
    dirName = r"F:\开阔者"
    tree_dir(dirName)


